eststo clear
use "$data/demog_meta.dta", clear
*drop outliers
egen p999=pctile(loan_amount), p(99.9)
drop if loan_amount>p999
keep if loan_amount>=50
keep if as_of>=2010
egen p999_rate=pctile(rate_spread), p(99.9)
keep if rate_spread<p999_rate
keep respond as_of rate_spread loan_am
drop if rate_spread==.
drop if rate_spread<5
gen treat=0
replace treat=1 if rate_spread>=5.75

sort as_of treat
collapse (sum) loan_amount, by(as_of treat)
binscatter loan_amount as_of , by(treat) line(connect) xline(2014) ytitle(1000 Dollars) xtitle(Year)/*
*/legend(label(1 "Rate Spread 5 to 5.75%") label(2 "Rate Spread Above 5.75%"))
graph export "$figures/total_credit_above50.eps", as(eps) preview(on) replace



eststo clear
use "$data/demog_meta.dta", clear
*drop outliers
egen p999=pctile(loan_amount), p(99.9)
drop if loan_amount>p999
keep if loan_amount<50
keep if as_of>=2010
egen p999_rate=pctile(rate_spread), p(99.9)
keep if rate_spread<p999_rate
keep respond as_of rate_spread loan_am
drop if rate_spread==.
drop if rate_spread<7
gen treat=0
replace treat=1 if rate_spread>=7.75

sort as_of treat
collapse (sum) loan_amount, by(as_of treat)
binscatter loan_amount as_of , by(treat) line(connect) xline(2014) ytitle(1000 Dollars) xtitle(Year)/*
*/legend(label(1 "Rate Spread 7 to 7.75%") label(2 "Rate Spread Above 7.75%"))
graph export "$figures/total_credit_below50.eps", as(eps) preview(on) replace









